import 'package:flutter/material.dart';
import 'package:get/get.dart';

import '../app/routes/app_pages.dart';
import '../tools/screenAdapter.dart';

PreferredSizeWidget appBar(flag, {keyWord}) {
  return AppBar(
    title: InkWell(
      onTap: () {
        Get.toNamed(Routes.SEARCH);
      },
      child: Container(
        width: ScreenAdapter.width(840),
        height: ScreenAdapter.height(96),
        decoration: BoxDecoration(
          color: const Color.fromRGBO(246, 246, 246, 1),
          borderRadius: BorderRadius.circular(30),
        ),
        child: Row(
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            Padding(
              padding: EdgeInsets.fromLTRB(
                ScreenAdapter.width(34),
                0,
                ScreenAdapter.width(10),
                0,
              ),
              child: const Icon(Icons.search), // 增加 const 优化性能
            ),
            Text(
              '${keyWord ?? ""}',
              style: TextStyle(fontSize: ScreenAdapter.fontSize(32)),
            ),
          ],
        ),
      ),
    ),
    centerTitle: true,
    actions: flag
        ? [
            IconButton(
              onPressed: () {},
              icon: const Icon(Icons.message_outlined, color: Colors.black54),
            ),
          ]
        : [Text('')],
  );
}
